</div>
<script src="__PUBLIC__/layui/layui.js"></script>
<script>
    var message;
    layui.config({
        base: '__JS__/',
        version: '1.0.1'
    }).use(['app', 'message'], function () {
        var app = layui.app,
            $ = layui.jquery,
            layer = layui.layer;
        //将message设置为全局以便子页面调用
        message = layui.message;
        //主入口
        app.set({
            type: 'iframe'
        }).init();

        $('dl.skin > dd').on('click', function () {
            var $that = $(this);
            var skin = $that.children('a').data('skin');
            switchSkin(skin);
        });
        var setSkin = function (value) {
                layui.data('kit_skin', {
                    key: 'skin',
                    value: value
                });
            },
            getSkinName = function () {
                return layui.data('kit_skin').skin;
            },
            switchSkin = function (value) {
                var _target = $('link[kit-skin]')[0];
                _target.href = _target.href.substring(0, _target.href.lastIndexOf('/') + 1) + value + _target.href.substring(_target.href.lastIndexOf('.'));
                setSkin(value);
            },
            initSkin = function () {
                var skin = getSkinName();
                switchSkin(skin === undefined ? 'default' : skin);
            }();

        $('#color').click(function () {
            layer.open({
                type: 1,
                title: '配色方案',
                area: ['290px', 'calc(100% - 52px)'],
                offset: 'rb',
                shadeClose: true,
                id: 'colors',
                anim: 2,
                shade: 0.2,
                closeBtn: 0,
                isOutAnim: false,
                resize: false,
                move: false,
                skin: 'color-class',
                btn: ['黑白格', '橘子橙', '原谅绿', '少女粉', '天空蓝', '枫叶红'],
                yes: function (index, layero) {
                    switchSkin('default');
                }
                , btn2: function (index, layero) {
                    switchSkin('orange');
                    return false;
                }
                , btn3: function (index, layero) {
                    switchSkin('green');
                    return false;
                }
                , btn4: function (index, layero) {
                    switchSkin('pink');
                    return false;
                }
                , btn5: function (index, layero) {
                    switchSkin('blue.1');
                    return false;
                }
                , btn6: function (index, layero) {
                    switchSkin('red');
                    return false;
                }

            });
        })
    });
</script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script src="__PUBLIC__/socket.io.js"></script>
<script type="text/javascript">

    layui.use('jquery', function () {
        var $ = layui.jquery;
        $('#clear').on('click', function () {
            var the = $(this).find('i');
            the.attr("class", "fa fa-spinner");
            $.ajax({
                url: "{:url('admin/common/clear')}"
                , success: function (res) {
                    if (res.code == 1) {
                        setTimeout(function () {
                            parent.message.show({
                                skin: 'cyan',
                                msg: res.msg
                            });
                            $('#clear i').attr("class", "fa fa-institution");
                        }, 1000)
                    }
                }
            })
        });
    });

    $('#logout').click(function () {
        layer.confirm('真的要退出?', {icon: 3, title: '提示', anim: 2}, function (index) {
            $.ajax({
                url: "{:url('admin/common/logout')}"
                , success: function (res) {
                    layer.msg(res.msg, {offset: '250px', anim: 4});
                    if (res.code == 1) {
                        setTimeout(function () {
                            location.href = res.url;
                        }, 2000)
                    }
                }
            })
        })
    })

    $('.layui-nav-item').click(function () {
        $(this).siblings('li').attr('class', 'layui-nav-item');
    })
</script>

<script type="text/javascript">
    layui.use('layer', function () {
        var layer = layui.layer;
        var remember = '';

        $('#tag').click(function () {
            var tag = localStorage.getItem("tag");
            layer.prompt({
                formType: 2,
                anim: 1,
                offset: ['52px', 'calc(100% - 500px)'],
                value: tag,
                title: '全站广播',
                skin: 'demo-class',
                area: ['280px', '150px'],
                id: 'remember',//设定一个id，防止重复弹出
                btn: ['写好了', '忘了吧'],
                shade: 0,
                moveType: 1, //拖拽模式，0或者1
                btn2: function (index, layero) {
                    localStorage.removeItem("tag");
                    $('#remember textarea').val('');
                    return false;
                }
            }, function (value, index, elem) {
                localStorage.setItem("tag", value);
                socket.emit('news',{data:value,pwd:pwd})
            })
        });
    });
</script>

</body>
</html>